From bd2f982c489b15ce1165c051fdedf35af979f784 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 8 Sep 2026 17:06:51 +0200 Subject: Migrate date handling from Date to Temporal API Routine scheduling, health series, service stamps, session expiry, and date formatting move to native Temporal (Instant / ZonedDateTime in UTC), with ISO strings kept at DB and chart boundaries. Ambient types in src/temporal-ambient.d.ts cover the native runtime; no polyfill. Observable behavior and stored formats are unchanged. --- .../routine/[routineId]/+page.server.ts | 4 +++- .../[projectId]/routine/[routineId]/+page.svelte | 28 +++++++++------------- 2 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/routes/projects/[projectId]') diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts b/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts index df4c2cc..bdfa452 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.server.ts @@ -26,7 +26,9 @@ export const load: PageServerLoad = async ({ params }) => { const completions = await loadCompletions(routineId); // An archived routine is frozen at its archive instant: state and chart // stop there instead of now. - const at = routine.archivedAt ? Date.parse(routine.archivedAt) : Date.now(); + const at = routine.archivedAt + ? Temporal.Instant.from(routine.archivedAt) + : Temporal.Now.instant(); return { project: { id: project.id, name: project.name }, routine, diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte index ab2644d..e593ad1 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte @@ -8,6 +8,7 @@ parseIntervalToDays, computeHealthSeries, } from '$lib/shared/routine-metrics'; + import { formatDayMonth, formatDayMonthYear } from '$lib/shared/temporal'; let { data, form } = $props(); let name = $state(''); let frequency = $state(''); @@ -27,24 +28,19 @@ } }); const frequencyDays = $derived(parseIntervalToDays(frequency)); - const dateFormatter = new Intl.DateTimeFormat('fr-FR', { - day: 'numeric', - month: 'short', - }); - const dateTimeFormatter = new Intl.DateTimeFormat('fr-FR', { - day: 'numeric', - month: 'short', - year: 'numeric', - }); const frozenAt = $derived( data.routine.archived - ? Date.parse(data.routine.archivedAt ?? data.routine.createdAt) - : Date.now(), + ? Temporal.Instant.from(data.routine.archivedAt ?? data.routine.createdAt) + : Temporal.Now.instant(), ); const series = $derived( computeHealthSeries(data.routine, data.completions, frozenAt), ); - const markers = $derived(data.completions.map((c) => Date.parse(c.doneAt))); + const markers = $derived( + data.completions.map( + (c) => Temporal.Instant.from(c.doneAt).epochMilliseconds, + ), + );
@@ -60,9 +56,7 @@ {#if data.routine.archived}

Archivée le - {dateTimeFormatter.format( - new Date(data.routine.archivedAt ?? data.routine.createdAt), - )} + {formatDayMonthYear(data.routine.archivedAt ?? data.routine.createdAt)}

{/if} @@ -144,7 +138,7 @@ {formatFrequency(data.routine.frequencyDays)} {#if data.state.lastDoneAt} - · fait le {dateFormatter.format(new Date(data.state.lastDoneAt))} + · fait le {formatDayMonth(data.state.lastDoneAt)} {:else} · jamais fait {/if} @@ -182,7 +176,7 @@ {#each data.completions as c (c.id)}
  • - {dateTimeFormatter.format(new Date(c.doneAt))} + {formatDayMonthYear(c.doneAt)} {#if c.note} {c.note} -- cgit v1.3